package com.itheima.mapper.db;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.domain.db.Log;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface LogMapper extends BaseMapper<Log> {
//自定义SQL

    //根据类型和时间统计用户数
    @Select("select count(distinct user_id) from tb_log where type = #{type} and log_time = #{time} ")
    public Integer findTypeAndTime(@Param("type") String type ,@Param("time") String time);

    //今日活跃用户数，根据时间统计用户数
    @Select("select count(distinct user_id) from tb_log where log_time = #{time}")
    public Integer findByTime(String time);

    //根据昨天和今天统计注册用户数
    @Select("select count(distinct user_id) from tb_log where log_time = #{today} " +
            "and user_Id in(select distinct user_id from tb_log where type = '0101' and log_time =#{yesterday})")
    public Integer findByTodayAndYesterday(@Param("today") String today ,@Param("yesterday") String yesterday);

}